﻿using UnityEngine;
using System.Collections;
using CHFramework;

public class UIPausePanel : BaseUI
{
    public GameObject QuitBtn;
    public GameObject CloseBtn;

	private void Awake () 
	{
        base.CurrentUIType.PanelType = UIPanelType.Popup;
        base.CurrentUIType.ShowMode = UIPanelShowMode.Normal;

        EventTriggerListener.Get(QuitBtn).onClick = OnQuit;
        EventTriggerListener.Get(CloseBtn).onClick = OnClose;
    }

    /// <summary>
    /// 退出
    /// </summary>
    /// <param name="sender"></param>
    private void OnQuit(GameObject sender)
    {
        UIManager.Instance.LoadSceneSync("GameLobby", () => 
        {
            UIManager.Instance.CloseUIPanel(EnumPanel.UIPausePanel);
            UIManager.Instance.CloseUIPanel(EnumPanel.UIInGamePanel);
        }, null, () => 
        {
            Time.timeScale = 1;
            UIManager.Instance.ShowUIPanel(EnumPanel.UIMainPanel);
            UIManager.Instance.ShowUIPanel(EnumPanel.UITopMainPanel);
            UIManager.Instance.CloseUIPanel(EnumPanel.UILoginPanel);
        });
    }

    /// <summary>
    /// 关闭
    /// </summary>
    /// <param name="sender"></param>
    private void OnClose(GameObject sender)
    {
        Time.timeScale = 1;
        UIManager.Instance.CloseUIPanel(EnumPanel.UIPausePanel);
    }
}
